package com.smooth.site.sx.pc.jifen.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.smooth.common.site.common.rsp.ReturnResult;
import com.smooth.dao.gen.bean.BizGoods;
import com.smooth.site.sx.pc.jifen.service.PcGoodsService;
import com.smooth.sys.pc.vo.ListRsp;
import com.smooth.sys.pc.vo.req.PcBaseReq;

@Controller
@RequestMapping(value = "/pc")
public class PcGoodsController {
	@Autowired
	PcGoodsService pcGoodsService;
	/**
	 * 学生注册
	 * @param studenRegVo
	 * @param result
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = {"p/goods/list"},method = {RequestMethod.POST,RequestMethod.GET})
	@ResponseBody
	public ReturnResult list(@Valid PcBaseReq pcBaseReq, BindingResult result,HttpServletRequest request, HttpServletResponse response) {
		ReturnResult returnResult = new ReturnResult();
		ListRsp<BizGoods> brsp = pcGoodsService.queryGoodsList(pcBaseReq.getLimit(), pcBaseReq.getOffset());
		returnResult.setData(brsp);
		return returnResult;
	}
	
	
	@RequestMapping(value = {"p/goods/detail"},method = {RequestMethod.POST,RequestMethod.GET})
	@ResponseBody
	public ReturnResult detail(@RequestParam(value = "id",required=true)String id, HttpServletRequest request, HttpServletResponse response) {
		ReturnResult returnResult = new ReturnResult();
		BizGoods bizGoods = pcGoodsService.queryGoodsDetail(id);
		returnResult.setData(bizGoods);
		return returnResult;
	}
	
}
